
#ifndef RANDOMRANGEPRO_H_

#define RANDOMRANGEPRO_H_

#include <vector>
#include <algorithm>

#include "common.h"
#include "random.h"

class RandomRangePro{
	public:
		RandomRangePro( uint32_t start, uint32_t end, uint32_t count )
			: start_(start), end_(end), index_(0), count_(count) {

			sequence_.resize( count );

			uint32_t i = 0;
			while ( i<count ){
				uint32_t s = rng.uniform( start, end-1 );
				if (!hasSequence(s)){
					sequence_[i] = s;
					i++;
				}
			}

		}

		bool hasNext() const{
			return index_<sequence_.size();
		}

		bool hasSequence( uint32_t seq ){
			return (std::find( sequence_.begin(), sequence_.end(), seq )!= sequence_.end() );
		}

		uint32_t next(){
			if ( index_<sequence_.size() ){
				return sequence_[index_++];
			}
			else
				return invalid_sequence;
		}
	private:
		std::vector<uint32_t> sequence_;
		uint32_t start_;
		uint32_t end_;
		uint32_t index_;
		uint32_t count_;
		static const uint32_t invalid_sequence;
};

#endif /* RANDOMRANGEPRO_H_ */

